package com.observer;

import com.alibaba.fastjson.JSON;
import com.observer.event.listener.MessageEventListener;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MinibusTargetService {

    private Logger logger =
            LoggerFactory.getLogger(MinibusTargetService.class);

    /**
     * 模拟摇号，但不是摇号算法
     *
     * @param uId ⽤户编号
     * @return 结果
     */
    public String lottery(String uId) {
        return Math.abs(uId.hashCode()) % 2 == 0 ? "恭喜你，编 码".concat(uId).concat("在本次摇号中签") : "很遗憾，编 码".concat(uId).concat("在本次摇号未中签或摇号资格已过期");
    }

    @Test
    public void test() {
        LotteryService lotteryService = new LotteryServiceImpl();
        LotteryResult result = lotteryService.draw("2765789109876");
        logger.info("测试结果：{}", JSON.toJSONString(result));
    }
}